Repository navigation
fix(android): clip children to the rounded corners and draw the border over them - #17
Merged
Merged
Conversation
…r over them A view with a border and a border radius used a BorderDrawable as its background and cleared the outline: its children were not clipped and drew over the corners of the border (a square child poked out of a rounded view). When the view has a border radius (no box shadow, no clip path) the outline now clips the children to the rounded corners. With a border width, the background drawable draws only the fill and a second BorderDrawable draws only the border as the foreground, over the children. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is the current behavior?
On Android a view with a border and a border radius draws its border as a
BorderDrawablebackground and clears the outline. Its children are not clipped, so a square child (e.g. an image) pokes out of the rounded corners and covers the border there. iOS already clips children to the rounded layer and draws the border on top.What is the new behavior?
When the view has a border radius (no box shadow, no clip path, uniform radii below Android 13) the outline clips the children to the rounded corners.
With a border width, the background
BorderDrawabledraws only the fill (refreshBorderDrawable(view, drawable, 'background')) and a secondBorderDrawabledraws only the border ('border') as the view foreground, over the children. Needs API 23 for the foreground, API 21 without a border width. No native change.Manual test (no unit test: native Android drawing): a
GridLayoutwithborderRadius,borderWidthand anImagechild. Checked on an Android emulator: the image is clipped to the corner and the border is drawn over it.Not covered here: other views with a radius and a border holding children now clip on Android; worth a glance in apps/automated.
🤖 Generated with Claude Code